<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://www.springside.org.cn/tags/shiro" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
	<title>管理</title>

	
	
	<!-- select2组合框 -->
	<link rel="stylesheet" type="text/css" href="${ctx}/static/metronic/assets/plugins/select2/select2_metro.css"/>
	<script type="text/javascript" src="${ctx}/static/metronic/assets/plugins/select2/select2.min.js"></script>
	<link rel="stylesheet" type="text/css" href="${ctx}/static/metronic/assets/plugins/bootstrap-datepicker/css/datepicker.css"/>
	<script type="text/javascript" src="${ctx}/static/metronic/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
	<link rel="stylesheet" type="text/css" href="${ctx}/static/metronic/assets/plugins/bootstrap-fileupload/bootstrap-fileupload.css"/>
	<script type="text/javascript" src="${ctx}/static/metronic/assets/plugins/bootstrap-fileupload/bootstrap-fileupload.js"></script>
	
		<script type="text/javascript" src="${ctx}/static/ckeditor/ckeditor.js"></script>
		<script type="text/javascript" src="${ctx}/static/scripts/jquery.MultiFile.js"></script>
		<script type="text/javascript" src="${ctx}/static/scripts/jquery.form.js"></script>
		<script type="text/javascript" src="${ctx}/static/scripts/jquery.MetaData.js"></script>
	<script type="text/javascript" src="${ctx}/static/ckeditor/adapters/jquery.js"></script>
    <script>
	$(document).ready(function() {
			
		$("#inputForm").validate({
            errorElement: 'span', //default input error message container
            errorClass: 'help-block', // default input error message class
            focusInvalid: false, // do not focus the last invalid input
            ignore: ".ignore",

            highlight: function (element) { // hightlight error inputs
                $(element).closest('.form-group').removeClass('has-success').addClass('has-error'); // set error class to the control group   
                var icon = $(element).parent('.input-icon').children('i');
            	icon.addClass("fa-warning").removeClass("fa-check");
            },

            unhighlight: function (element) { // revert the change done by hightlight
                $(element).closest('.form-group').removeClass('has-error').addClass('has-success'); // set success class to the control group
                var icon = $(element).parent('.input-icon').children('i');
                icon.removeClass("fa-warning").addClass("fa-check");
            },

            success: function (label, element) {
                $(element).closest('.form-group').removeClass('has-error').addClass('has-success'); // set success class to the control group
                var icon = $(element).parent('.input-icon').children('i');
                icon.removeClass("fa-warning").addClass("fa-check");
            }
        });
		
	});
	
	function del(uuid,id){
		var id =$("#id").val();
		var url=$("#url").val();
		$.get(
			"${ctx}/selfConstruction/delAttac/",
			{
				"uuid":uuid,
				"id":id
			},
			function(data){
				var htmls = "";
				$.each(data,function(i,d){
					htmls+="<a href='"+url+"'"+i+">"+d+"</a>&nbsp;&nbsp;&nbsp;<a href='javascript:del("+i+","+id+")'"+" style='color:red;' >X</a><br/>"
				})
				$("#attac").html(htmls);
				//改变内容后重新渲染一下
			},
			"json"
		);
	}
	</script>
</head>

<body>
<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
			<div class="row">
				<div class="col-md-12">
					<div class="portlet box green">
						<div class="portlet-title">
							<div class="caption">
								<i class="fa fa-reorder"></i>${action=='create' ? '创建' : action=='update' ? '编辑' : '查看'}自身建设
							</div>
						</div>
						<div class="portlet-body form">
							<!-- BEGIN FORM-->
							<form id="inputForm" action="${ctx}/selfConstruction/${action}" enctype="multipart/form-data" method="post" class="form-horizontal">
							<input type="hidden" id="id" name="id" value="${selfConstruction.id}"/>
							<input type="hidden" id="url" name="url" value="${uploadUrl }"/>
							<div id="messageBox" class="alert alert-error input-large controls" style="display:none">输入有误，请先更正。</div>
								<div class="form-body">
									<div class="form-group">
										<label class="col-md-3 control-label">标题：</label>
										<div class="col-md-4">
											<div class="input-icon right">
												<i class="fa"></i>
											<input type="text" id="title" name="title" class="form-control required" maxlength="255" placeholder="输入标题" value="${selfConstruction.title}" ${action=='view'?'disabled':''}>
											</div>
										</div>
									</div>
								</div>
								
								
							
								<div class="form-body">
									<div class="form-group">
										<label class="col-md-3 control-label">所属栏目</label>
										<div class="col-md-4">
											<div class="input-icon right">
												<i class="fa"></i>
												<select name="classify" id="classify" class="form-control input-small select2me" data-placeholder="选择所属栏目" ${action=='view'?'disabled':''}>
													<c:forEach items="${types}" var="p">
														<option value="${p.key}" ${selfConstruction.classify==p.key ? "selected=\"selected\"" : ""}>${p.value}</option>
													</c:forEach>
												</select>
											</div>
										</div>
									</div>
								</div>
							
								
								
								
							
							
								<div class="form-body">
									<div class="form-group">
										<label class="col-md-3 control-label">内容：</label>
										<div class="col-md-4">
											<div class="input-icon right">
												<i class="fa"></i>
												<textarea name="content" class="form-control " rows="18"
													maxlength="20000" placeholder="输入内容"
													${action=='view'?'disabled':''}>${selfConstruction.content}</textarea>
											</div>
										</div>
									</div>
								</div>

								<script type="text/javascript">CKEDITOR.replace( 'content',{skin : "moono",width:520,height:520} );</script>
								
								<div class="form-body">
									<div class="form-group">
										<label class="col-md-3 control-label">附件：</label>
										<div class="col-md-4">
											<div class="span7">

									<!-- The fileinput-button span is used to style the file input field as button -->

									<span class="btn  fileinput-button">

									<i class="icon-plus "></i>

									<span></span>

									<input type="file" name="file" multiple class="multi">

									</span>


								</div>
										</div>
									</div>
								</div>
								
							<c:if test="${!empty fls}">
								<div class="form-body">
									<div class="form-group">
										<label class="col-md-3 control-label">已上传附件</label>
										<div class="col-md-4">
											<div class="input-icon right" id="attac">
												<i class="fa"></i>
													<c:forEach items="${fls}" var="p">
														<a href="${uploadUrl }/${p.key}">${ p.value}</a>&nbsp;&nbsp;&nbsp;<a href='javascript:del("${p.key }",${ selfConstruction.id})' class='' style="color:red">X</a><br/>
													</c:forEach>
											</div>
										</div>
									</div>
								</div>
									</c:if>
								
												<div class="form-actions fluid">
									<div class="col-md-offset-3 col-md-9">
												<button type="reset" class="btn blue">全部重填</button>
												<button type="submit" class="btn blue">正式发布</button>
										<button type="button" class="btn default" onclick="history.back()">返回</button>
									</div>
								</div>
							</form>
							<!-- END FORM-->
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	


</body>
</html>
